Imports System.Data
Imports System.Xml
Imports System.Data.SqlClient
Imports AppsUtility.EncDec

Public Class frmGLLedgerEnquiry
    Inherits System.Windows.Forms.Form
    Dim util As New AppsUtility.EncDec
    Public strCon As String = util.toDecrypt(System.Configuration.ConfigurationSettings.AppSettings("SQLString"))
    Public OpgBal As Decimal = 0
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents GroupPanel1 As DevComponents.DotNetBar.Controls.GroupPanel
    Friend WithEvents PanelEx1 As DevComponents.DotNetBar.PanelEx
    Friend WithEvents cmbChart As DevComponents.DotNetBar.Controls.ComboBoxEx
    Friend WithEvents cmdExit As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdPrint As DevComponents.DotNetBar.ButtonX
    Friend WithEvents cmdRefresh As DevComponents.DotNetBar.ButtonX
    Friend WithEvents lblOp As System.Windows.Forms.Label
    Public ClgBal As Decimal = 0
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Label9 As System.Windows.Forms.Label
    Friend WithEvents Label10 As System.Windows.Forms.Label
    Friend WithEvents dtpFromDate As System.Windows.Forms.DateTimePicker
    Friend WithEvents dtpToDate As System.Windows.Forms.DateTimePicker
    Friend WithEvents dgTrxEnq As System.Windows.Forms.DataGrid
    Friend WithEvents tbOpbal As System.Windows.Forms.TextBox
    Friend WithEvents tbTotalDr As System.Windows.Forms.TextBox
    Friend WithEvents tbTotalCr As System.Windows.Forms.TextBox
    Friend WithEvents tbClBal As System.Windows.Forms.TextBox
    Friend WithEvents tbNum As System.Windows.Forms.TextBox
    Friend WithEvents tbDpt As System.Windows.Forms.TextBox
    Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip
    Friend WithEvents gLlistOfEnquiry1 As GLlistOfEnquiry
    Friend WithEvents lblCl As System.Windows.Forms.Label

    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label8 = New System.Windows.Forms.Label()
        Me.tbOpbal = New System.Windows.Forms.TextBox()
        Me.tbTotalDr = New System.Windows.Forms.TextBox()
        Me.Label9 = New System.Windows.Forms.Label()
        Me.tbTotalCr = New System.Windows.Forms.TextBox()
        Me.tbClBal = New System.Windows.Forms.TextBox()
        Me.Label10 = New System.Windows.Forms.Label()
        Me.dtpFromDate = New System.Windows.Forms.DateTimePicker()
        Me.dtpToDate = New System.Windows.Forms.DateTimePicker()
        Me.dgTrxEnq = New System.Windows.Forms.DataGrid()
        Me.tbNum = New System.Windows.Forms.TextBox()
        Me.tbDpt = New System.Windows.Forms.TextBox()
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.gLlistOfEnquiry1 = New GLlistOfEnquiry()
        Me.lblCl = New System.Windows.Forms.Label()
        Me.Label4 = New System.Windows.Forms.Label()
        Me.Label3 = New System.Windows.Forms.Label()
        Me.GroupPanel1 = New DevComponents.DotNetBar.Controls.GroupPanel()
        Me.cmdExit = New DevComponents.DotNetBar.ButtonX()
        Me.cmdPrint = New DevComponents.DotNetBar.ButtonX()
        Me.cmdRefresh = New DevComponents.DotNetBar.ButtonX()
        Me.PanelEx1 = New DevComponents.DotNetBar.PanelEx()
        Me.cmbChart = New DevComponents.DotNetBar.Controls.ComboBoxEx()
        Me.lblOp = New System.Windows.Forms.Label()
        CType(Me.dgTrxEnq, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupPanel1.SuspendLayout()
        Me.PanelEx1.SuspendLayout()
        Me.SuspendLayout()
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label2.Location = New System.Drawing.Point(606, 11)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(54, 18)
        Me.Label2.TabIndex = 53
        Me.Label2.Text = "To Date"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label1.Location = New System.Drawing.Point(480, 11)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(72, 18)
        Me.Label1.TabIndex = 51
        Me.Label1.Text = "From Date"
        '
        'Label8
        '
        Me.Label8.AutoSize = True
        Me.Label8.BackColor = System.Drawing.Color.Transparent
        Me.Label8.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label8.Location = New System.Drawing.Point(756, 11)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(67, 18)
        Me.Label8.TabIndex = 81
        Me.Label8.Text = "OPB. Amt"
        '
        'tbOpbal
        '
        Me.tbOpbal.BackColor = System.Drawing.Color.White
        Me.tbOpbal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbOpbal.Location = New System.Drawing.Point(759, 31)
        Me.tbOpbal.Name = "tbOpbal"
        Me.tbOpbal.ReadOnly = True
        Me.tbOpbal.Size = New System.Drawing.Size(113, 26)
        Me.tbOpbal.TabIndex = 82
        Me.tbOpbal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'tbTotalDr
        '
        Me.tbTotalDr.BackColor = System.Drawing.Color.White
        Me.tbTotalDr.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbTotalDr.Location = New System.Drawing.Point(671, 366)
        Me.tbTotalDr.Name = "tbTotalDr"
        Me.tbTotalDr.ReadOnly = True
        Me.tbTotalDr.Size = New System.Drawing.Size(100, 26)
        Me.tbTotalDr.TabIndex = 84
        Me.tbTotalDr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label9
        '
        Me.Label9.AutoSize = True
        Me.Label9.BackColor = System.Drawing.Color.Transparent
        Me.Label9.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label9.Location = New System.Drawing.Point(583, 345)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(38, 18)
        Me.Label9.TabIndex = 83
        Me.Label9.Text = "Total"
        '
        'tbTotalCr
        '
        Me.tbTotalCr.BackColor = System.Drawing.Color.White
        Me.tbTotalCr.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbTotalCr.Location = New System.Drawing.Point(774, 366)
        Me.tbTotalCr.Name = "tbTotalCr"
        Me.tbTotalCr.ReadOnly = True
        Me.tbTotalCr.Size = New System.Drawing.Size(113, 26)
        Me.tbTotalCr.TabIndex = 85
        Me.tbTotalCr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'tbClBal
        '
        Me.tbClBal.BackColor = System.Drawing.Color.White
        Me.tbClBal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbClBal.Location = New System.Drawing.Point(671, 394)
        Me.tbClBal.Name = "tbClBal"
        Me.tbClBal.ReadOnly = True
        Me.tbClBal.Size = New System.Drawing.Size(100, 26)
        Me.tbClBal.TabIndex = 87
        Me.tbClBal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        '
        'Label10
        '
        Me.Label10.AutoSize = True
        Me.Label10.BackColor = System.Drawing.Color.Transparent
        Me.Label10.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label10.Location = New System.Drawing.Point(583, 372)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(82, 18)
        Me.Label10.TabIndex = 86
        Me.Label10.Text = "Clg. Balance"
        '
        'dtpFromDate
        '
        Me.dtpFromDate.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
        Me.dtpFromDate.Location = New System.Drawing.Point(479, 31)
        Me.dtpFromDate.Name = "dtpFromDate"
        Me.dtpFromDate.Size = New System.Drawing.Size(106, 26)
        Me.dtpFromDate.TabIndex = 153
        '
        'dtpToDate
        '
        Me.dtpToDate.Format = System.Windows.Forms.DateTimePickerFormat.[Short]
        Me.dtpToDate.Location = New System.Drawing.Point(607, 31)
        Me.dtpToDate.Name = "dtpToDate"
        Me.dtpToDate.Size = New System.Drawing.Size(107, 26)
        Me.dtpToDate.TabIndex = 154
        '
        'dgTrxEnq
        '
        Me.dgTrxEnq.BackColor = System.Drawing.Color.AliceBlue
        Me.dgTrxEnq.BackgroundColor = System.Drawing.Color.AliceBlue
        Me.dgTrxEnq.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.dgTrxEnq.CaptionVisible = False
        Me.dgTrxEnq.DataMember = ""
        Me.dgTrxEnq.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dgTrxEnq.Location = New System.Drawing.Point(6, 118)
        Me.dgTrxEnq.Name = "dgTrxEnq"
        Me.dgTrxEnq.PreferredColumnWidth = 175
        Me.dgTrxEnq.ReadOnly = True
        Me.dgTrxEnq.Size = New System.Drawing.Size(881, 236)
        Me.dgTrxEnq.TabIndex = 155
        Me.dgTrxEnq.TabStop = False
        '
        'tbNum
        '
        Me.tbNum.BackColor = System.Drawing.Color.White
        Me.tbNum.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbNum.Location = New System.Drawing.Point(8, 31)
        Me.tbNum.MaxLength = 4
        Me.tbNum.Name = "tbNum"
        Me.tbNum.Size = New System.Drawing.Size(66, 26)
        Me.tbNum.TabIndex = 196
        '
        'tbDpt
        '
        Me.tbDpt.BackColor = System.Drawing.Color.White
        Me.tbDpt.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.tbDpt.Location = New System.Drawing.Point(75, 31)
        Me.tbDpt.MaxLength = 3
        Me.tbDpt.Name = "tbDpt"
        Me.tbDpt.Size = New System.Drawing.Size(51, 26)
        Me.tbDpt.TabIndex = 197
        '
        'lblCl
        '
        Me.lblCl.Location = New System.Drawing.Point(699, 372)
        Me.lblCl.Name = "lblCl"
        Me.lblCl.Size = New System.Drawing.Size(43, 11)
        Me.lblCl.TabIndex = 199
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label4.Location = New System.Drawing.Point(135, 10)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(58, 18)
        Me.Label4.TabIndex = 51
        Me.Label4.Text = "Account"
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.Label3.Location = New System.Drawing.Point(7, 10)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(55, 18)
        Me.Label3.TabIndex = 51
        Me.Label3.Text = "Acc.No."
        '
        'GroupPanel1
        '
        Me.GroupPanel1.CanvasColor = System.Drawing.SystemColors.Control
        Me.GroupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.GroupPanel1.Controls.Add(Me.PanelEx1)
        Me.GroupPanel1.Controls.Add(Me.cmdExit)
        Me.GroupPanel1.Controls.Add(Me.cmdPrint)
        Me.GroupPanel1.Controls.Add(Me.cmdRefresh)
        Me.GroupPanel1.Controls.Add(Me.Label9)
        Me.GroupPanel1.Controls.Add(Me.Label10)
        Me.GroupPanel1.Dock = System.Windows.Forms.DockStyle.Fill
        Me.GroupPanel1.Location = New System.Drawing.Point(0, 0)
        Me.GroupPanel1.Name = "GroupPanel1"
        Me.GroupPanel1.Size = New System.Drawing.Size(896, 480)
        '
        '
        '
        Me.GroupPanel1.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.GroupPanel1.Style.BackColorGradientAngle = 90
        Me.GroupPanel1.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.GroupPanel1.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderBottomWidth = 1
        Me.GroupPanel1.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.GroupPanel1.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderLeftWidth = 1
        Me.GroupPanel1.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderRightWidth = 1
        Me.GroupPanel1.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid
        Me.GroupPanel1.Style.BorderTopWidth = 1
        Me.GroupPanel1.Style.CornerDiameter = 4
        Me.GroupPanel1.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded
        Me.GroupPanel1.Style.TextAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Center
        Me.GroupPanel1.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.GroupPanel1.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near
        Me.GroupPanel1.TabIndex = 201
        Me.GroupPanel1.Text = "GL-Ledger - Enquiry"
        '
        'cmdExit
        '
        Me.cmdExit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdExit.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdExit.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdExit.Location = New System.Drawing.Point(802, 415)
        Me.cmdExit.Name = "cmdExit"
        Me.cmdExit.Size = New System.Drawing.Size(82, 27)
        Me.cmdExit.TabIndex = 234
        Me.cmdExit.Text = "Exit"
        '
        'cmdPrint
        '
        Me.cmdPrint.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdPrint.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdPrint.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdPrint.Location = New System.Drawing.Point(624, 416)
        Me.cmdPrint.Name = "cmdPrint"
        Me.cmdPrint.Size = New System.Drawing.Size(82, 26)
        Me.cmdPrint.TabIndex = 233
        Me.cmdPrint.Text = "Print"
        '
        'cmdRefresh
        '
        Me.cmdRefresh.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton
        Me.cmdRefresh.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.cmdRefresh.ForeColor = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(64, Byte), Integer))
        Me.cmdRefresh.Location = New System.Drawing.Point(714, 416)
        Me.cmdRefresh.Name = "cmdRefresh"
        Me.cmdRefresh.Size = New System.Drawing.Size(82, 26)
        Me.cmdRefresh.TabIndex = 232
        Me.cmdRefresh.Text = "Refresh"
        '
        'PanelEx1
        '
        Me.PanelEx1.CanvasColor = System.Drawing.SystemColors.Control
        Me.PanelEx1.ColorScheme.ItemDesignTimeBorder = System.Drawing.Color.Black
        Me.PanelEx1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007
        Me.PanelEx1.Controls.Add(Me.lblOp)
        Me.PanelEx1.Controls.Add(Me.cmbChart)
        Me.PanelEx1.Controls.Add(Me.tbOpbal)
        Me.PanelEx1.Controls.Add(Me.Label8)
        Me.PanelEx1.Controls.Add(Me.dtpFromDate)
        Me.PanelEx1.Controls.Add(Me.tbNum)
        Me.PanelEx1.Controls.Add(Me.Label2)
        Me.PanelEx1.Controls.Add(Me.tbDpt)
        Me.PanelEx1.Controls.Add(Me.dtpToDate)
        Me.PanelEx1.Controls.Add(Me.Label4)
        Me.PanelEx1.Controls.Add(Me.Label1)
        Me.PanelEx1.Controls.Add(Me.Label3)
        Me.PanelEx1.Location = New System.Drawing.Point(3, 14)
        Me.PanelEx1.Name = "PanelEx1"
        Me.PanelEx1.Size = New System.Drawing.Size(881, 71)
        Me.PanelEx1.Style.Alignment = System.Drawing.StringAlignment.Center
        Me.PanelEx1.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground
        Me.PanelEx1.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2
        Me.PanelEx1.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine
        Me.PanelEx1.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder
        Me.PanelEx1.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText
        Me.PanelEx1.Style.GradientAngle = 90
        Me.PanelEx1.TabIndex = 87
        '
        'cmbChart
        '
        Me.cmbChart.DisplayMember = "Text"
        Me.cmbChart.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed
        Me.cmbChart.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cmbChart.ItemHeight = 19
        Me.cmbChart.Location = New System.Drawing.Point(132, 31)
        Me.cmbChart.Name = "cmbChart"
        Me.cmbChart.Size = New System.Drawing.Size(284, 25)
        Me.cmbChart.TabIndex = 196
        '
        'lblOp
        '
        Me.lblOp.AutoSize = True
        Me.lblOp.BackColor = System.Drawing.Color.Transparent
        Me.lblOp.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.lblOp.Location = New System.Drawing.Point(693, 0)
        Me.lblOp.Name = "lblOp"
        Me.lblOp.Size = New System.Drawing.Size(67, 18)
        Me.lblOp.TabIndex = 81
        Me.lblOp.Text = "OPB. Amt"
        Me.lblOp.Visible = False
        '
        'frmGLLedgerEnquiry
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(7, 19)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaption
        Me.ClientSize = New System.Drawing.Size(896, 480)
        Me.ControlBox = False
        Me.Controls.Add(Me.dgTrxEnq)
        Me.Controls.Add(Me.tbClBal)
        Me.Controls.Add(Me.tbTotalCr)
        Me.Controls.Add(Me.tbTotalDr)
        Me.Controls.Add(Me.lblCl)
        Me.Controls.Add(Me.GroupPanel1)
        Me.Font = New System.Drawing.Font("Calibri", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ForeColor = System.Drawing.SystemColors.ControlLightLight
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
        Me.Location = New System.Drawing.Point(50, 70)
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.Name = "frmGLLedgerEnquiry"
        Me.ShowInTaskbar = False
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        CType(Me.dgTrxEnq, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupPanel1.ResumeLayout(False)
        Me.GroupPanel1.PerformLayout()
        Me.PanelEx1.ResumeLayout(False)
        Me.PanelEx1.PerformLayout()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region
    Private Sub Budgets_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ds2 As DataSet
        Dim GLdata As New GLdataLogic
        ds2 = GLdata.GetAccountsByCompany(CompanyID, 0, 0)
        cmbChart.DataSource = ds2.Tables(0)
        cmbChart.ValueMember = "AccountID"
        cmbChart.DisplayMember = "AccountName"
        GLdata = Nothing
    End Sub
    Private Sub dgTrxEnq_load()
        Try
            Dim FrDt, ToDt As String
            FrDt = dtpFromDate.Text
            ToDt = dtpToDate.Text
            FrDt = FrDt.Substring(6, 4) & "-" & FrDt.Substring(3, 2) & "-" & FrDt.Substring(0, 2)
            ToDt = ToDt.Substring(6, 4) & "-" & ToDt.Substring(3, 2) & "-" & ToDt.Substring(0, 2)
            Dim strsql As String
            Dim sqlCon As SqlConnection = New SqlConnection(strCon)
            sqlCon.Open()
            If CompanyID > 1 Then
                strsql = "select TrxDate,TrxSource,TrxAmt DrAmount,null CrAmount,TrxRefer,TrxNumber,VOUCHER from GLTRX " & _
                "where AcNum='" & tbNum.Text & "' and AcCent='" & tbDpt.Text & "' and " & _
                "(TrxDate between '" & FrDt & "' and '" & ToDt & "') " & _
                "and TrxAmt>0 " & _
                "UNION ALL " & _
                "select TrxDate,TrxSource,null DrAmount,Abs(TrxAmt) CrAmount,TrxRefer,TrxNumber,VOUCHER from GLTRX " & _
                "where AcNum='" & tbNum.Text & "' and AcCent='" & tbDpt.Text & "' and " & _
                "(TrxDate between '" & FrDt & "' and '" & ToDt & "') " & _
                "and TrxAmt<0 " & _
                " order by TrxDate "
            Else
                strsql = "select TrxDate,TrxSource,TrxAmt DrAmount,null CrAmount,TrxRefer,TrxNumber,VOUCHER from GLTRX " & _
                "where AcNum='" & tbNum.Text & "'  and " & _
                "(TrxDate between '" & FrDt & "' and '" & ToDt & "') " & _
                "and TrxAmt>0 " & _
                "UNION ALL " & _
                "select TrxDate,TrxSource,null DrAmount,Abs(TrxAmt) CrAmount,TrxRefer,TrxNumber,VOUCHER from GLTRX " & _
                "where AcNum='" & tbNum.Text & "'  and " & _
                "(TrxDate between '" & FrDt & "' and '" & ToDt & "') " & _
                "and TrxAmt<0 " & _
                " order by TrxDate "
            End If
            Dim da As New SqlClient.SqlDataAdapter(strsql, sqlCon)
            Dim ds As New DataSet("TRENQ")
            da.Fill(ds, "TRENQ")
            dgTrxEnq.DataSource = ds
            dgTrxEnq.DataMember = "TRENQ"
            dgTrxEnq.ReadOnly = True
            dgTrxEnq.TableStyles.Clear()
            dgTrxEnq_Style()
            Dim drow As DataRow
            Dim DrTotal As Decimal = 0
            Dim CrTotal As Decimal = 0
            For Each drow In ds.Tables(0).Rows
                If Not IsDBNull(drow("DrAmount")) Then
                    DrTotal += drow("DrAmount")
                End If
                If Not IsDBNull(drow("CrAmount")) Then
                    CrTotal += drow("CrAmount")
                End If
            Next
            If OpgBal > 0 Then
                DrTotal = DrTotal + OpgBal
            Else
                CrTotal = CrTotal + OpgBal
            End If
            tbTotalDr.Text = DrTotal.ToString("#,##0.000")
            tbTotalCr.Text = CrTotal.ToString("#,##0.000")
            sqlCon.Close()
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

    Private Sub dgTrxEnq_Style()
        With dgTrxEnq
            .TableStyles.Clear()
            .CaptionBackColor = System.Drawing.Color.SlateBlue
            .CaptionForeColor = System.Drawing.Color.LemonChiffon
            .AllowSorting = True
            .AlternatingBackColor = System.Drawing.Color.AliceBlue
            .ParentRowsBackColor = System.Drawing.Color.Lavender
            .ParentRowsForeColor = System.Drawing.Color.SlateBlue
            .HeaderBackColor = System.Drawing.Color.LemonChiffon
            .AllowNavigation = False
            .ParentRowsVisible = False
            .RowHeadersVisible = False
        End With

        Dim grdTableStyle As New DataGridTableStyle
        With grdTableStyle
            .AlternatingBackColor = Color.AliceBlue
            .HeaderFont = New Font("Calibri", 9.0!, FontStyle.Bold)
            .MappingName = "TRENQ"
            .PreferredColumnWidth = 160
            .HeaderBackColor = Color.LightSlateGray
            .HeaderForeColor = Color.LightCyan
            .PreferredRowHeight = 15
            .RowHeadersVisible = False
            .RowHeaderWidth = 0
        End With



        Dim cs As DataGridColumnStyle
        cs = New DataGridTextBoxColumn
        cs.Width = 90
        cs.MappingName = "TrxDate"
        cs.HeaderText = "Date"
        cs.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs)

        Dim cs1 As DataGridColumnStyle
        cs1 = New DataGridTextBoxColumn
        cs1.Width = 90
        cs1.MappingName = "TrxSource"
        cs1.HeaderText = "Refer#"
        cs1.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs1)

        Dim cs2 As DataGridColumnStyle
        cs2 = New DataGridTextBoxColumn  ' Add the standard column style.
        cs2.Width = 190
        cs2.MappingName = "TrxRefer"
        cs2.HeaderText = "Description"
        cs2.NullText = ""
        cs2.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs2)

        'Dim cs2 As DataGridColumnStyle
        cs2 = New DataGridTextBoxColumn  ' Add the standard column style.
        cs2.Width = 190
        cs2.MappingName = "VOUCHER"
        cs2.HeaderText = "Voucher"
        cs2.NullText = ""
        cs2.ReadOnly = True
        grdTableStyle.GridColumnStyles.Add(cs2)

        Dim cs3 As DataGridColumnStyle
        cs3 = New DataGridTextBoxColumn
        cs3.Width = 95
        cs3.MappingName = "TrxNumber"
        cs3.HeaderText = "Trx.No."
        cs3.NullText = ""
        grdTableStyle.GridColumnStyles.Add(cs3)

        Dim cs0 As DataGridColumnStyle
        cs0 = New DataGridTextBoxColumn  ' Add the standard column style.
        cs0.Width = 110
        cs0.MappingName = "DrAmount"
        cs0.HeaderText = "Debit Amount "
        cs0.NullText = ""
        cs0.ReadOnly = True
        cs0.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs0)

        Dim cs4 As DataGridColumnStyle
        cs4 = New DataGridTextBoxColumn  ' Add the standard column style.
        cs4.Width = 110
        cs4.MappingName = "CrAmount"
        cs4.HeaderText = "Credit Amount "
        cs4.NullText = ""
        cs4.ReadOnly = True
        cs4.Alignment = HorizontalAlignment.Right
        grdTableStyle.GridColumnStyles.Add(cs4)

        dgTrxEnq.TableStyles.Add(grdTableStyle)

    End Sub

    Private Function GetBBFQty()
        Try
            Dim FrDt, ToDt As String
            FrDt = dtpFromDate.Text
            ToDt = dtpToDate.Text
            FrDt = FrDt.Substring(6, 4) & "-" & FrDt.Substring(3, 2) & "-" & FrDt.Substring(0, 2)
            ToDt = ToDt.Substring(6, 4) & "-" & ToDt.Substring(3, 2) & "-" & ToDt.Substring(0, 2)

            Dim strsql As String
            Dim sqlCon As SqlConnection = New SqlConnection(strCon)
            sqlCon.Open()
            Dim sqlCMD As New SqlCommand(strsql, sqlCon)
            If CompanyID > 1 Then
                strsql = "Select isnull(Sum(TrxAmt),0) Q from GlTrx " & _
                         " Where AcNum='" & tbNum.Text & "' and AcCent='" & tbDpt.Text & "' " & _
                         " and (TrxDate < '" & FrDt & "') "
            Else
                strsql = "Select isnull(Sum(TrxAmt),0) Q from GlTrx " & _
                         " Where AcNum='" & tbNum.Text & "'  " & _
                         " and (TrxDate < '" & FrDt & "') "

            End If
            sqlCMD.CommandText = strsql
            If sqlCon.State = ConnectionState.Closed Then
                sqlCon.Open()
            End If
            Dim rdr As SqlDataReader
            rdr = sqlCMD.ExecuteReader
            Dim BFQty As Double = 0
            If rdr.HasRows Then
                While rdr.Read
                    BFQty = rdr("Q")
                End While
            End If
            rdr.Close()
            sqlCon.Close()
            Dim amt As String = BFQty.ToString("#,##0.000")
            OpgBal = amt
            If BFQty < 0 Then
                tbOpbal.Text = amt.Replace("-", "")
                lblOp.Text = "Cr"
            Else
                tbOpbal.Text = amt.Replace("-", "")
                lblOp.Text = "Dr"
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Function

    Private Function GetClosingQty()
        Try
            Dim FrDt, ToDt As String
            FrDt = dtpFromDate.Text
            ToDt = dtpToDate.Text
            FrDt = FrDt.Substring(6, 4) & "-" & FrDt.Substring(3, 2) & "-" & FrDt.Substring(0, 2)
            ToDt = ToDt.Substring(6, 4) & "-" & ToDt.Substring(3, 2) & "-" & ToDt.Substring(0, 2)

            Dim strsql As String
            Dim sqlCon As SqlConnection = New SqlConnection(strCon)
            sqlCon.Open()
            Dim sqlCMD As New SqlCommand(strsql, sqlCon)
            If CompanyID > 1 Then
                strsql = "Select isnull(Sum(TrxAmt),0) Q from GlTrx " & _
                         " Where AcNum='" & tbNum.Text & "' and AcCent='" & tbDpt.Text & "' " & _
                         " and (TrxDate <= '" & ToDt & "') "
            Else
                strsql = "Select isnull(Sum(TrxAmt),0) Q from GlTrx " & _
                         " Where AcNum='" & tbNum.Text & "'  " & _
                         " and (TrxDate <= '" & ToDt & "') "
            End If
            sqlCMD.CommandText = strsql
            If sqlCon.State = ConnectionState.Closed Then
                sqlCon.Open()
            End If
            Dim rdr As SqlDataReader
            rdr = sqlCMD.ExecuteReader
            Dim BFQty As Double = 0
            If rdr.HasRows Then
                While rdr.Read
                    BFQty = rdr("Q")
                End While
            End If
            rdr.Close()
            sqlCon.Close()
            Dim amt As String = BFQty.ToString("#,##0.000")
            If BFQty < 0 Then
                tbClBal.Text = amt.Replace("-", "")
                lblCl.Text = "Cr"
            Else
                tbClBal.Text = amt.Replace("-", "")
                lblCl.Text = "Dr"
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Function

    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        Me.Hide()
    End Sub

    Private Sub cmdRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRefresh.Click
        Me.Cursor = Cursors.WaitCursor
        GetBBFQty()
        dgTrxEnq_load()
        GetClosingQty()
        Me.Cursor = Cursors.Default
    End Sub
    Private Sub cmbChart_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        AutoCompleteCombo_KeyUp(cmbChart, e)
        If e.KeyCode = Keys.Enter Then
            SendKeys.Send("{Tab}")
        End If
    End Sub
    Private Sub cmbChart_Leave(ByVal sender As Object, ByVal e As System.EventArgs)
        AutoCompleteCombo_Leave(cmbChart)
    End Sub
    Private Sub cmbChart_Validated(ByVal sender As Object, ByVal e As System.EventArgs)
        If IsNumeric(cmbChart.SelectedValue) Then
            Dim AcID As Integer
            AcID = cmbChart.SelectedValue
            Dim GLdata As New GLdataLogic
            Dim ds3 As DataSet
            ds3 = GLdata.GetAccountDetailsByAccountID(AcID)
            tbNum.Text = ds3.Tables(0).Rows(0).Item("AccountNumber")
            tbDpt.Text = ds3.Tables(0).Rows(0).Item("AccountCenter")
            GLdata = Nothing
        End If
    End Sub

    Private Sub cmbChart_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If IsNumeric(cmbChart.SelectedValue) Then
            Dim AcID As Integer
            AcID = cmbChart.SelectedValue
            Dim GLdata As New GLdataLogic
            Dim ds3 As DataSet
            ds3 = GLdata.GetAccountDetailsByAccountID(AcID)
            tbNum.Text = ds3.Tables(0).Rows(0).Item("AccountNumber")
            tbDpt.Text = ds3.Tables(0).Rows(0).Item("AccountCenter")
            GLdata = Nothing
        End If
    End Sub

    Private Sub dgTrxEnq_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles dgTrxEnq.MouseUp
        Dim pt As New Point(e.X, e.Y)
        Dim hti As DataGrid.HitTestInfo = dgTrxEnq.HitTest(pt)
        If hti.Type = DataGrid.HitTestType.Cell Then
            dgTrxEnq.CurrentCell = New DataGridCell(hti.Row, hti.Column)
            dgTrxEnq.Select(hti.Row)
        End If
    End Sub
    Private Sub tbNum_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbNum.Validated
        If tbNum.Text.Trim() <> "" And tbDpt.Text.Trim <> "" Then
            If ValidateAccountCode() = False Then
                MsgBox("Invalid Account", MsgBoxStyle.Critical, "Inventory Manager")
                tbNum.Text = ""
                tbDpt.Text = ""
                tbNum.Focus()
            End If
        End If
    End Sub
    Private Function ValidateAccountCode() As Boolean
        Dim GLdata As New GLdataLogic
        Try
            Dim ds As DataSet
            ds = GLdata.GetAccountDetails(CompanyID, tbNum.Text, tbDpt.Text)
            If ds.Tables(0).Rows.Count() = 0 Then
                GLdata = Nothing
                Return False
            End If
            cmbChart.SelectedValue = ds.Tables(0).Rows(0).Item("AccountID")
            Return True
        Catch ex As Exception
            GLdata = Nothing
            'MsgBox("Unable to satisfy your request." & vbLf & "Try again later.", MsgBoxStyle.Critical, "Inventory Manager")
            Return False
        End Try
    End Function
    Private Sub tbNum_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbNum.KeyUp
        If e.KeyCode = Keys.Enter Then
            If tbNum.Text <> "" Then
                SendKeys.Send("{Tab}")
            Else
                tbDpt.Focus()
            End If
        End If
    End Sub

    Private Sub tbDpt_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbDpt.KeyUp
        If e.KeyCode = Keys.Enter Then
            If tbDpt.Text = "" Then
                tbDpt.Text = "000"
            End If
            SendKeys.Send("{Tab}")
        End If
    End Sub
    Private Sub tbDpt_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles tbDpt.Validated
        If tbDpt.Text.Trim = "" Then
            tbDpt.Text = "000"
        End If
        If tbNum.Text.Trim() <> "" And tbDpt.Text.Trim <> "" Then
            If ValidateAccountCode() = False Then
                MsgBox("Invalid Account", MsgBoxStyle.Critical, "Inventory Manager")
                tbNum.Text = ""
                tbDpt.Text = ""
                tbNum.Focus()
            End If
        End If
    End Sub

    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
        Me.Cursor = Cursors.WaitCursor
        Try
            Dim ds As DataSet = New DataSet("JisRpt")
            Dim table As DataTable = New DataTable("JisRpt")
            table.Columns.Add("Str1")
            table.Columns.Add("Str2")
            table.Columns.Add("Str3")
            table.Columns.Add("Str4")
            table.Columns.Add("Str5")
            table.Columns.Add("Dec1")
            table.Columns.Add("Dec2")

            Dim mrow, drow As Integer
            Dim cm As CurrencyManager = BindingContext(dgTrxEnq.DataSource, dgTrxEnq.DataMember)
            Dim dv As DataView = cm.List
            dv.RowStateFilter = DataViewRowState.CurrentRows
            mrow = dv.Count
            Dim n As Integer
            Dim orow As DataRow = table.NewRow()
            orow("Str3") = "OPENING BALANCE:"
            If Decimal.Parse(tbOpbal.Text.Replace(",", "")) >= 0 Then
                orow("Dec1") = Decimal.Parse(tbOpbal.Text.Replace(",", ""))
            Else
                orow("Dec2") = Decimal.Parse(tbOpbal.Text.Replace(",", ""))
            End If
            table.Rows.Add(orow)
            For n = 0 To mrow - 1
                Dim nrow As DataRow = table.NewRow()
                nrow("Str1") = Format(CDate(dgTrxEnq.Item(n, 0)), "dd/MM/yyyy")
                nrow("Str2") = dgTrxEnq(n, 1)
                nrow("Str3") = dgTrxEnq(n, 2)
                nrow("Str4") = dgTrxEnq(n, 4)
                nrow("Str5") = dgTrxEnq(n, 3)
                nrow("Dec1") = dgTrxEnq(n, 5)
                nrow("Dec2") = dgTrxEnq(n, 6)
                table.Rows.Add(nrow)
            Next
            Dim trow As DataRow = table.NewRow()
            trow("Str3") = "TOTAL:"
            trow("Dec1") = Decimal.Parse(tbTotalDr.Text.Replace(",", ""))
            trow("Dec2") = Decimal.Parse(tbTotalCr.Text.Replace(",", ""))
            table.Rows.Add(trow)

            Dim crow As DataRow = table.NewRow()
            crow("Str3") = "CLOSING BALANCE:"
            If Decimal.Parse(tbClBal.Text) >= 0 Then
                crow("Dec1") = Decimal.Parse(tbClBal.Text.Replace(",", ""))
            Else
                crow("Dec2") = Decimal.Parse(tbClBal.Text.Replace(",", ""))
            End If
            table.Rows.Add(crow)

            ds.Tables.Add(table)
            gLlistOfEnquiry1.Load()
            gLlistOfEnquiry1.SetDataSource(ds)

            gLlistOfEnquiry1.SetParameterValue("CompanyName", CompanyTitle)
            gLlistOfEnquiry1.SetParameterValue("ReportName", cmbChart.Text + " (" + tbNum.Text + "-" + tbDpt.Text + ")")
            gLlistOfEnquiry1.SetParameterValue("ReportCriteria", "A/C ENQUIRY FOR THE PERIOD FROM:" + dtpFromDate.Text + " TO: " + dtpToDate.Text)
            gLlistOfEnquiry1.SetParameterValue("un", UserName)
            If PrntPrv Is Nothing Then
                PrntPrv = New PrintPreviewForm
                PrntPrv.CrRptView.ReportSource = gLlistOfEnquiry1
                PrntPrv.ShowDialog()
            End If

            'gLlistOfEnquiry1.PrintToPrinter(1, True, 0, 0)
            gLlistOfEnquiry1.Close()

        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        Me.Cursor = Cursors.Default
    End Sub

  
End Class
